home *** CD-ROM | disk | FTP | other *** search
/ Micromanía 92 / CDMM92_1.ISO / SOF 2 SDK / sof2sdk-101.msi / _92D6AC311BB48EBA344BBABC89DA6AB0 / _DF354264F9EF4240B8AACF942546945F < prev    next >
Encoding:
Text File  |  2002-06-17  |  33.5 KB  |  1,560 lines

  1. // Copyright (C) 2001-2002 Raven Software
  2. //
  3. // bg_misc.c -- both games misc functions, all completely stateless
  4.  
  5. #include "q_shared.h"
  6. #include "bg_public.h"
  7.  
  8. #ifdef QAGAME
  9. #include "g_local.h"
  10. #endif
  11.  
  12. #ifdef UI_EXPORTS
  13. #include "../ui/ui_local.h"
  14. #endif
  15.  
  16. #ifndef UI_EXPORTS
  17. #ifndef QAGAME
  18. #include "../cgame/cg_local.h"
  19. #endif
  20. #endif
  21.  
  22. /*QUAKED item_***** ( 0 0 0 ) (-16 -16 -16) (16 16 16) suspended
  23. DO NOT USE THIS CLASS, IT JUST HOLDS GENERAL INFORMATION.
  24. The suspended flag will allow items to hang in the air, otherwise they are dropped to the next surface.
  25.  
  26. If an item is the target of another entity, it will not spawn in until fired.
  27.  
  28. An item fires all of its targets when it is picked up.  If the toucher can't carry it, the targets won't be fired.
  29.  
  30. "notfree" if set to 1, don't spawn in free for all games
  31. "notteam" if set to 1, don't spawn in team games
  32. "notsingle" if set to 1, don't spawn in single player games
  33. "wait"    override the default wait before respawning.  -1 = never respawn automatically, which can be used with targeted spawning.
  34. "random" random number of plus or minus seconds varied from the respawn time
  35. "count" override quantity or duration on most items.
  36. */
  37.  
  38. gitem_t    bg_itemlist[] = 
  39. {
  40.     {
  41.         NULL,                // classname    
  42.         NULL,                // pickup_sound
  43.         {    NULL,            // world_model[0]
  44.             NULL,            // world_model[1]
  45.             0, 0} ,            // world_model[2],[3]
  46. /* icon */        NULL,        // icon
  47.                 NULL,
  48.                 NULL,
  49. /* pickup */    NULL,        // pickup_name
  50.         0,                    // quantity
  51.         0,                    // giType (IT_*)
  52.         0,                    // giTag
  53. /* precache */ "",            // precaches
  54. /* sounds */ ""                // sounds
  55.     },    // leave index 0 alone
  56.  
  57.     //
  58.     // Pickups
  59.     //
  60.  
  61. /*QUAKED pickup_armor_big (0 .6 .6) (-15 -15 -15) (15 15 15) 
  62. */
  63.     {
  64.         "pickup_armor_big", 
  65.         "sound/player/pickup/armour.wav",
  66.         { "models/pick_ups/armor_large.md3",
  67.         0, 0, 0},
  68. /* icon */        "gfx/menus/hud/weapon_icons/armor_large_icon",
  69.                 "",
  70.                 "some",
  71. /* pickup */    "Heavy Armor",
  72.         75,
  73.         IT_ARMOR,
  74.         0,
  75. /* precache */ "",
  76. /* sounds */ "",
  77.  
  78.     },
  79.  
  80. /*QUAKED pickup_armor_medium (0 .6 .6) (-15 -15 -15) (15 15 15) 
  81. */
  82.     {
  83.         "pickup_armor_medium", 
  84.         "sound/player/pickup/armour.wav",
  85.         { "models/pick_ups/armor_medium.md3",
  86.         0, 0, 0},
  87. /* icon */        "gfx/menus/hud/weapon_icons/armor_medium_icon",
  88.                 "",
  89.                 "some",
  90. /* pickup */    "Medium Armor",
  91.         50,
  92.         IT_ARMOR,
  93.         0,
  94. /* precache */ "",
  95. /* sounds */ "",
  96.  
  97.     },
  98.  
  99. /*QUAKED pickup_armor_small (0 .6 .6) (-15 -15 -15) (15 15 15) 
  100. */    
  101.     {
  102.         "pickup_armor_small", 
  103.         "sound/player/pickup/armour.wav",
  104.         { "models/pick_ups/armor_small.md3",
  105.         0, 0, 0},
  106. /* icon */        "gfx/menus/hud/weapon_icons/armor_small_icon",
  107.                 "",
  108.                 "some",
  109. /* pickup */    "Small Armor",
  110.         25,
  111.         IT_ARMOR,
  112.         0,
  113. /* precache */ "",
  114. /* sounds */ "",
  115.  
  116.     },
  117.  
  118. /*QUAKED pickup_health_big (0 .6 .6) (-15 -15 -15) (15 15 15) 
  119. */
  120.     {
  121.         "pickup_health_big",
  122.         "sound/player/pickup/health.wav",
  123.         { "models/pick_ups/health_lrg.md3", 
  124.         0, 0, 0 },
  125. /* icon */        "gfx/menus/hud/weapon_icons/health_large_icon",
  126.                 "",
  127.                 "a",
  128. /* pickup */    "Large Health",
  129.         100,
  130.         IT_HEALTH,
  131.         0,
  132. /* precache */ "",
  133. /* sounds */ ""
  134.     },
  135.  
  136. /*QUAKED pickup_health_small (0 .6 .6) (-15 -15 -15) (15 15 15) 
  137. */
  138.     {
  139.         "pickup_health_small",
  140.         "sound/player/pickup/health.wav",
  141.         { "models/pick_ups/health_smll.md3", 
  142.         0, 0, 0 },
  143. /* icon */        "gfx/menus/hud/weapon_icons/health_small_icon",
  144.                 "",
  145.                 "a",
  146. /* pickup */    "Small Health",
  147.         25,
  148.         IT_HEALTH,
  149.         0,
  150. /* precache */ "",
  151. /* sounds */ ""
  152.     },
  153.  
  154.     //
  155.     // ITEMS
  156.     //
  157.  
  158.  
  159.     //
  160.     // WEAPONS 
  161.     //
  162.  
  163. /*Q U A K E D weapon_knife (.3 .3 1) (-15 -15 -15) (15 15 15) suspended
  164. Don't place this
  165. */
  166.     {
  167.         "weapon_knife", 
  168.         "sound/weapons/knife/ready.wav",
  169.         { "models/weapons/knife/world/knifeworld.glm",
  170.         0, 0, 0},
  171. /* icon */        "gfx/menus/hud/weapon_icons/knife_icon",
  172.                 "*gfx/menus/weapon_renders/knife",
  173.                 "a",
  174. /* pickup */    "Knife",
  175.         -1,
  176.         IT_WEAPON,
  177.         WP_KNIFE,
  178. /* precache */ "",
  179. /* sounds */ "",
  180.  
  181.         OUTFITTING_GROUP_KNIFE
  182.     },
  183.  
  184. /*QUAKED pickup_weapon_US_SOCOM (0 .6 .6) (-15 -15 -15) (15 15 15) 
  185. Pistol, uses 45 rounds
  186. */
  187.     {
  188.         "pickup_weapon_US_SOCOM", 
  189.         "sound/player/pickup/weapon.wav",
  190.         { "models/weapons/ussocom/world/ussocomworld.glm", 
  191.         0, 0, 0},
  192. /* icon */        "gfx/menus/hud/weapon_icons/ussocom_icon",
  193.                 "*gfx/menus/weapon_renders/ussocom_mp",
  194.                 "a",
  195. /* pickup */    "US SOCOM",
  196.         10,
  197.         IT_WEAPON,
  198.         WP_USSOCOM_PISTOL,
  199. /* precache */ "",
  200. /* sounds */ "",
  201.  
  202.         OUTFITTING_GROUP_PISTOL,
  203.     },
  204.  
  205. /*QUAKED pickup_weapon_M19 (0 .6 .6) (-15 -15 -15) (15 15 15) 
  206. Pistol, uses 45 rounds
  207. */
  208.     {
  209.         "pickup_weapon_M19", 
  210.         "sound/player/pickup/weapon.wav",
  211.         { "models/weapons/m1911a1/world/m1911a1world.glm", 
  212.         0, 0, 0},
  213. /* icon */        "gfx/menus/hud/weapon_icons/m1911a1_icon",
  214.                 "*gfx/menus/weapon_renders/m1911a1",
  215.                 "a",
  216. /* pickup */    "M1911A1",
  217.         12,
  218.         IT_WEAPON,
  219.         WP_M1911A1_PISTOL,
  220. /* precache */ "",
  221. /* sounds */ "",
  222.  
  223.         OUTFITTING_GROUP_PISTOL,
  224.     },
  225.  
  226. /*QUAKED pickup_weapon_microuzi (0 .6 .6) (-15 -15 -15) (15 15 15) 
  227. Sub-Machinegun, uses 9mm rounds
  228. */
  229.     {
  230.         "pickup_weapon_microuzi", 
  231.         "sound/player/pickup/weapon.wav",
  232.         { "models/weapons/microuzi/world/microuziworld.glm", 
  233.         0, 0, 0},
  234. /* icon */        "gfx/menus/hud/weapon_icons/microuzi_icon",
  235.                 "*gfx/menus/weapon_renders/microuzi",
  236.                 "a",
  237. /* pickup */    "MicroUzi",
  238.         30,
  239.         IT_WEAPON,
  240.         WP_MICRO_UZI_SUBMACHINEGUN,
  241. /* precache */ "",
  242. /* sounds */ "",
  243.  
  244.         OUTFITTING_GROUP_SECONDARY,
  245.     },
  246.  
  247. /*QUAKED pickup_weapon_M3A1 (0 .6 .6) (-15 -15 -15) (15 15 15) 
  248. Sub-Machinegun, uses 45 rounds
  249. */
  250.     {
  251.         "pickup_weapon_M3A1", 
  252.         "sound/player/pickup/weapon.wav",
  253.         { "models/weapons/m3a1/world/m3a1world.glm", 
  254.         0, 0, 0},
  255. /* icon */        "gfx/menus/hud/weapon_icons/m3a1_icon",
  256.                 "gfx/menus/weapon_renders/m3a1",
  257.                 "a",
  258. /* pickup */    "M3A1 Sub-machinegun",
  259.         30,
  260.         IT_WEAPON,
  261.         WP_M3A1_SUBMACHINEGUN,
  262. /* precache */ "",
  263. /* sounds */ "",
  264.  
  265.         OUTFITTING_GROUP_SECONDARY,
  266.     },
  267.  
  268. /*QUAKED pickup_weapon_USAS_12 (0 .6 .6) (-15 -15 -15) (15 15 15) 
  269. Shotgun, uses 12-gauge rounds
  270. ammo ---------- amount of ammo (defaults to 10)
  271. */
  272.     {
  273.         "pickup_weapon_USAS_12", 
  274.         "sound/player/pickup/weapon.wav",
  275.         { "models/weapons/usas12/world/usas12world.glm", 
  276.         0, 0, 0},
  277. /* icon */        "gfx/menus/hud/weapon_icons/usas12_icon",
  278.                 "gfx/menus/weapon_renders/usas12",
  279.                 "a",
  280. /* pickup */    "USAS12 SHOTGUN",
  281.         30,
  282.         IT_WEAPON,
  283.         WP_USAS_12_SHOTGUN,
  284. /* precache */ "",
  285. /* sounds */ "",
  286.         
  287.         OUTFITTING_GROUP_PRIMARY,
  288.     },
  289.  
  290. /*QUAKED pickup_weapon_M590 (0 .6 .6) (-15 -15 -15) (15 15 15) 
  291. Shotgun, uses 12-gauge rounds
  292. */
  293.     {
  294.         "pickup_weapon_M590", 
  295.         "sound/player/pickup/weapon.wav",
  296.         { "models/weapons/m590/world/m590world.glm", 
  297.         0, 0, 0},
  298. /* icon */        "gfx/menus/hud/weapon_icons/m590_icon",
  299.                 "gfx/menus/weapon_renders/m590",
  300.                 "a",
  301. /* pickup */    "M590",
  302.         30,
  303.         IT_WEAPON,
  304.         WP_M590_SHOTGUN,
  305. /* precache */ "",
  306. /* sounds */ "",
  307.  
  308.         OUTFITTING_GROUP_SECONDARY,
  309.     },
  310.  
  311. /*QUAKED pickup_weapon_MSG90A1 (0 .6 .6) (-15 -15 -15) (15 15 15) 
  312. Sniper Rifle, uses 7.62 rounds
  313. */
  314.     {
  315.         "pickup_weapon_MSG90A1", 
  316.         "sound/player/pickup/weapon.wav",
  317.         { "models/weapons/msg90a1/world/msg90a1world.glm", 
  318.         0, 0, 0},
  319. /* icon */        "gfx/menus/hud/weapon_icons/msg90a1_icon",
  320.                 "gfx/menus/weapon_renders/msg90a1",
  321.                 "a",
  322. /* pickup */    "MSG90A1 Sniper",
  323.         30,
  324.         IT_WEAPON,
  325.         WP_MSG90A1,
  326. /* precache */ "",
  327. /* sounds */ "",
  328.  
  329.         OUTFITTING_GROUP_PRIMARY,
  330.     },
  331.  
  332. /*QUAKED pickup_weapon_M4 (0 .6 .6) (-15 -15 -15) (15 15 15) 
  333. Assault Rifle, uses 5.56 rounds and 40mm grenades
  334. */
  335.     {
  336.         "pickup_weapon_M4", 
  337.         "sound/player/pickup/weapon.wav",
  338.         { "models/weapons/m4/world/m4world.glm", 
  339.         0, 0, 0},
  340. /* icon */        "gfx/menus/hud/weapon_icons/m4_icon",
  341.                 "gfx/menus/weapon_renders/m4_m203",
  342.                 "a",
  343. /* pickup */    "M4 Assault",
  344.         30,
  345.         IT_WEAPON,
  346.         WP_M4_ASSAULT_RIFLE,
  347. /* precache */ "",
  348. /* sounds */ "",
  349.  
  350.         OUTFITTING_GROUP_PRIMARY,
  351.     },
  352.  
  353. /*QUAKED pickup_weapon_AK_74 (0 .6 .6) (-15 -15 -15) (15 15 15) 
  354. Assault Rifle, uses 5.56 rounds
  355. */
  356.     {
  357.         "pickup_weapon_AK_74", 
  358.         "sound/player/pickup/weapon.wav",
  359.         { "models/weapons/ak74/world/ak74world.glm", 
  360.         0, 0, 0},
  361. /* icon */        "gfx/menus/hud/weapon_icons/ak74_icon",
  362.                 "gfx/menus/weapon_renders/ak74",
  363.                 "an",
  364. /* pickup */    "AK74 Assault",
  365.         30,
  366.         IT_WEAPON,
  367.         WP_AK74_ASSAULT_RIFLE,
  368. /* precache */ "",
  369. /* sounds */ "",
  370.  
  371.         OUTFITTING_GROUP_PRIMARY,
  372.     },
  373.  
  374. /*QUAKED pickup_weapon_M60 (0 .6 .6) (-15 -15 -15) (15 15 15) 
  375. Machinegun, uses 7.62 rounds
  376. */
  377.     {
  378.         "pickup_weapon_M60", 
  379.         "sound/player/pickup/weapon.wav",
  380.         { "models/weapons/m60/world/m60world.glm", 
  381.         0, 0, 0},
  382. /* icon */        "gfx/menus/hud/weapon_icons/m60_icon",
  383.                 "gfx/menus/weapon_renders/m60",
  384.                 "a",
  385. /* pickup */    "M60 Machinegun",
  386.         30,
  387.         IT_WEAPON,
  388.         WP_M60_MACHINEGUN,
  389. /* precache */ "",
  390. /* sounds */ "",
  391.  
  392.         OUTFITTING_GROUP_PRIMARY,
  393.     },
  394.  
  395. /*QUAKED pickup_weapon_RPG_7 (0 .6 .6) (-15 -15 -15) (15 15 15) 
  396. RPG, uses 40mm rounds
  397. */
  398.     {
  399.         "pickup_weapon_RPG_7", 
  400.         "sound/player/pickup/weapon.wav",
  401.         { "models/weapons/rpg7/world/rpg7world.glm", 
  402.         0, 0, 0},
  403. /* icon */        "gfx/menus/hud/weapon_icons/rpg7_icon",
  404.                 "gfx/menus/weapon_renders/rpg7",
  405.                 "a",
  406. /* pickup */    "RPG-7",
  407.         10,
  408.         IT_WEAPON,
  409.         WP_RPG7_LAUNCHER,
  410. /* precache */ "",
  411. /* sounds */ "",
  412.         
  413.         OUTFITTING_GROUP_PRIMARY,
  414.     },
  415.  
  416. /*QUAKED pickup_weapon_MM_1 (0 .6 .6) (-15 -15 -15) (15 15 15) 
  417. Grenade Launcher, uses 40mm rounds
  418. */
  419.     {
  420.         "pickup_weapon_MM_1", 
  421.         "sound/player/pickup/weapon.wav",
  422.         { "models/weapons/mm1/world/mm1world.glm", 
  423.         0, 0, 0},
  424. /* icon */        "gfx/menus/hud/weapon_icons/mm1_icon",
  425.                 "gfx/menus/weapon_renders/mm1",
  426.                 "a",
  427. /* pickup */    "MM1 Grenade Launcher",
  428.         10,
  429.         IT_WEAPON,
  430.         WP_MM1_GRENADE_LAUNCHER,
  431. /* precache */ "",
  432. /* sounds */ "",
  433.  
  434.         OUTFITTING_GROUP_PRIMARY,
  435.     },
  436.  
  437. /*QUAKED pickup_weapon_M84 (0 .6 .6) (-15 -15 -15) (15 15 15) 
  438. Grenade
  439. */
  440.     {
  441.         "pickup_weapon_M84", 
  442.         "sound/player/pickup/weapon.wav",
  443.         { "models/weapons/m84/world/m84world.glm", 
  444.         0, 0, 0},
  445. /* icon */        "gfx/menus/hud/weapon_icons/m84_icon",
  446.                 "*gfx/menus/weapon_renders/m84",
  447.                 "a",
  448. /* pickup */    "M84 Flash",
  449.         5,
  450.         IT_WEAPON,
  451.         WP_M84_GRENADE,
  452. /* precache */ "",
  453. /* sounds */ "",
  454.  
  455.         OUTFITTING_GROUP_GRENADE,
  456.     },
  457.  
  458. /*QUAKED pickup_weapon_SMOHG92 (0 .6 .6) (-15 -15 -15) (15 15 15) 
  459. Grenade
  460. */
  461.     {
  462.         "pickup_weapon_SMOHG92", 
  463.         "sound/player/pickup/weapon.wav",
  464.         { "models/weapons/smohg92/world/smohg92world.glm", 
  465.         0, 0, 0},
  466. /* icon */        "gfx/menus/hud/weapon_icons/smohg92_icon",
  467.                 "*gfx/menus/weapon_renders/smohg92",
  468.                 "a",
  469. /* pickup */    "SMOHG92 Frag",
  470.         5,
  471.         IT_WEAPON,
  472.         WP_SMOHG92_GRENADE,
  473. /* precache */ "",
  474. /* sounds */ "",
  475.  
  476.         OUTFITTING_GROUP_GRENADE,
  477.     },
  478.  
  479. /*QUAKED pickup_weapon_AN_M14 (0 .6 .6) (-15 -15 -15) (15 15 15) 
  480. Incendiary Grenade
  481. */
  482.     {
  483.         "pickup_weapon_AN_M14", 
  484.         "sound/player/pickup/weapon.wav",
  485.         { "models/weapons/anm14/world/anm14world.glm", 
  486.         0, 0, 0},
  487. /* icon */        "gfx/menus/hud/weapon_icons/anm14_icon",
  488.                 "*gfx/menus/weapon_renders/anm14",
  489.                 "an",
  490. /* pickup */    "ANM14 Incendiary",
  491.         5,
  492.         IT_WEAPON,
  493.         WP_ANM14_GRENADE,
  494. /* precache */ "",
  495. /* sounds */ "",
  496.  
  497.         OUTFITTING_GROUP_GRENADE,
  498.     },
  499.  
  500. /*QUAKED pickup_weapon_M15 (0 .6 .6) (-15 -15 -15) (15 15 15) 
  501. White Phosphorus Grenade
  502. */
  503.     {
  504.         "pickup_weapon_M15", 
  505.         "sound/player/pickup/weapon.wav",
  506.         { "models/weapons/m15/world/m15world.glm", 
  507.         0, 0, 0},
  508. /* icon */        "gfx/menus/hud/weapon_icons/m15_icon",
  509.                 "*gfx/menus/weapon_renders/m15",
  510.                 "a",
  511. /* pickup */    "M15 Smoke",
  512.         5,
  513.         IT_WEAPON,
  514.         WP_M15_GRENADE,
  515. /* precache */ "",
  516. /* sounds */ "",
  517.  
  518.         OUTFITTING_GROUP_GRENADE,
  519.     },
  520.  
  521. /*QUAKED pickup_weapon_MP5 (0 .6 .6) (-15 -15 -15) (15 15 15) 
  522. Sub-Machinegun, uses 9mm rounds
  523. */
  524.     {
  525.         "pickup_weapon_MP5", 
  526.         "sound/player/pickup/weapon.wav",
  527.         { "models/weapons/mp5/world/mp5world.glm", 
  528.         0, 0, 0},
  529. /* icon */        "gfx/menus/hud/weapon_icons/mp5_icon",
  530.                 "gfx/menus/weapon_renders/mp5",
  531.                 "a",
  532. /* pickup */    "MP5 Sub-machinegun",
  533.         30,
  534.         IT_WEAPON,
  535.         WP_MP5,
  536. /* precache */ "",
  537. /* sounds */ "",
  538.  
  539.         OUTFITTING_GROUP_PRIMARY,
  540.     },
  541.  
  542.     //
  543.     // AMMO ITEMS
  544.     //
  545.  
  546. /*QUAKED pickup_ammo_45 (0 .6 .6) (-15 -15 -15) (15 15 15) 
  547. */
  548.     {
  549.         "pickup_ammo_45",
  550.         "sound/player/pickup/ammo.wav",
  551.         { "models/pick_ups/ammo_45_smll.md3", 
  552.         0, 0, 0},
  553. /* icon */        "gfx/menus/hud/weapon_icons/ammo_45_icon",
  554.                 "",
  555.                 "some",
  556. /* pickup */    "0.45 ACP Ammo",
  557.         30,
  558.         IT_AMMO,
  559.         AMMO_045,
  560. /* precache */ "",
  561. /* sounds */ "",
  562.     },
  563.  
  564. /*QUAKED pickup_ammo_9mm (0 .6 .6) (-15 -15 -15) (15 15 15) 
  565. */
  566.     {
  567.         "pickup_ammo_9mm",
  568.         "sound/player/pickup/ammo.wav",
  569.         { "models/pick_ups/ammo_9mm_smll.md3", 
  570.         0, 0, 0},
  571. /* icon */        "gfx/menus/hud/weapon_icons/ammo_9mm_icon",
  572.                 "",
  573.                 "some",
  574. /* pickup */    "9mm Ammo",
  575.         30,
  576.         IT_AMMO,
  577.         AMMO_9,
  578. /* precache */ "",
  579. /* sounds */ "",
  580.     },
  581.  
  582. /*QUAKED pickup_ammo_12gauge (0 .6 .6) (-15 -15 -15) (15 15 15) 
  583. */
  584.     {
  585.         "pickup_ammo_12gauge",
  586.         "sound/player/pickup/ammo.wav",
  587.         { "models/pick_ups/ammo_shotgun_smll.md3", 
  588.         0, 0, 0},
  589. /* icon */        "gfx/menus/hud/weapon_icons/ammo_shotgun_icon",
  590.                 "",
  591.                 "some",
  592. /* pickup */    "Shotgun Ammo",
  593.         10,
  594.         IT_AMMO,
  595.         AMMO_12,
  596. /* precache */ "",
  597. /* sounds */ "",
  598.     },
  599.  
  600. /*QUAKED pickup_ammo_762 (0 .6 .6) (-15 -15 -15) (15 15 15) 
  601. */
  602.     {
  603.         "pickup_ammo_762",
  604.         "sound/player/pickup/ammo.wav",
  605.         { "models/pick_ups/ammo_762_smll.md3", 
  606.         0, 0, 0},
  607. /* icon */        "gfx/menus/hud/weapon_icons/ammo_762_icon",
  608.                 "",
  609.                 "some",
  610. /* pickup */    "7.62mm Ammo",
  611.         30,
  612.         IT_AMMO,
  613.         AMMO_762,
  614. /* precache */ "",
  615. /* sounds */ "",
  616.     },
  617.  
  618. /*QUAKED pickup_ammo_556 (0 .6 .6) (-15 -15 -15) (15 15 15) 
  619. */
  620.     {
  621.         "pickup_ammo_556",
  622.         "sound/player/pickup/ammo.wav",
  623.         { "models/pick_ups/ammo_556_smll.md3", 
  624.         0, 0, 0},
  625. /* icon */        "gfx/menus/hud/weapon_icons/ammo_556_icon",
  626.                 "",
  627.                 "some",
  628. /* pickup */    "5.56mm Ammo",
  629.         30,
  630.         IT_AMMO,
  631.         AMMO_556,
  632. /* precache */ "",
  633. /* sounds */ "",
  634.     },
  635.  
  636. /*QUAKED pickup_ammo_40mm (0 .6 .6) (-15 -15 -15) (15 15 15) 
  637. */
  638.     {
  639.         "pickup_ammo_40mm",
  640.         "sound/player/pickup/ammo.wav",
  641.         { "models/pick_ups/ammo_40_smll.md3", 
  642.         0, 0, 0},
  643. /* icon */        "gfx/menus/hud/weapon_icons/ammo_40mm_icon",
  644.                 "",
  645.                 "some",
  646. /* pickup */    "40mm Grenade Ammo",
  647.         5,
  648.         IT_AMMO,
  649.         AMMO_40,
  650. /* precache */ "",
  651. /* sounds */ "",
  652.     },
  653.  
  654.  
  655. /*QUAKED pickup_ammo_rpg7 (0 .6 .6) (-15 -15 -15) (15 15 15) 
  656. */
  657.     {
  658.         "pickup_ammo_rpg7",
  659.         "sound/player/pickup/ammo.wav",
  660.         { "models/pick_ups/ammo_rpg7_smll.md3", 
  661.         0, 0, 0},
  662. /* icon */        "gfx/menus/hud/weapon_icons/ammo_rpg_icon",
  663.                 "",
  664.                 "some",
  665. /* pickup */    "RPG7 Ammo",
  666.         5,
  667.         IT_AMMO,
  668.         AMMO_RPG7,
  669. /* precache */ "",
  670. /* sounds */ "",
  671.     },
  672.  
  673.  
  674. /*QUAKED pickup_backpack (0 .6 .6) (-15 -15 -15) (15 15 15) 
  675. */
  676.     {    // just a temp place holder
  677.         "pickup_backpack",
  678.         "sound/player/pickup/health.wav",
  679.         { "models/pick_ups/mp_universal_pickup.md3", 
  680.         0, 0, 0},
  681. /* icon */        "gfx/menus/hud/weapon_icons/mp_universal_pickup",
  682.                 "",
  683.                 "a ",
  684. /* pickup */    "Backpack",
  685.         0,
  686.         IT_BACKPACK,
  687.         0,
  688. /* precache */ "",
  689. /* sounds */ "",
  690.     },
  691.  
  692.     {
  693.         "gametype_item_1",
  694.         NULL,
  695.         { 0 },
  696.         "",
  697.         "",
  698.         "the",
  699.         "",
  700.         0,
  701.         IT_GAMETYPE,
  702.         0,
  703.         "",
  704.         ""
  705.     },
  706.  
  707.     {
  708.         "gametype_item_2",
  709.         NULL,
  710.         { 0 },
  711.         "",
  712.         "",
  713.         "the",
  714.         "",
  715.         0,
  716.         IT_GAMETYPE,
  717.         1,
  718.         "",
  719.         ""
  720.     },
  721.  
  722.     {
  723.         "gametype_item_3",
  724.         NULL,
  725.         { 0 },
  726.         "",
  727.         "",
  728.         "the",
  729.         "",
  730.         0,
  731.         IT_GAMETYPE,
  732.         2,
  733.         "",
  734.         ""
  735.     },
  736.  
  737.     {
  738.         "gametype_item_4",
  739.         NULL,
  740.         { 0 },
  741.         "",
  742.         "",
  743.         "the",
  744.         "",
  745.         0,
  746.         IT_GAMETYPE,
  747.         3,
  748.         "",
  749.         ""
  750.     },
  751.  
  752.     {
  753.         "gametype_item_5",
  754.         NULL,
  755.         { 0 },
  756.         "",
  757.         "",
  758.         "the",
  759.         "",
  760.         0,
  761.         IT_GAMETYPE,
  762.         4,
  763.         "",
  764.         ""
  765.     },
  766.  
  767.     {
  768.         "armor",
  769.         "sound/player/pickup/ammo.wav",
  770.         { 0 },
  771.         "gfx/menus/hud/weapon_icons/armor_icon",
  772.         "*gfx/menus/weapon_renders/armor",
  773.         "some",
  774.         "Armor",
  775.         5,
  776.         IT_PASSIVE,
  777.         0,
  778.         "",
  779.         "",
  780.         
  781.         OUTFITTING_GROUP_ACCESSORY
  782.     },
  783.  
  784.     {
  785.         "venhance_night_vision",
  786.         "sound/player/pickup/ammo.wav",
  787.         { 0 },
  788.         "gfx/menus/hud/weapon_icons/nightvision_icon",
  789.         "*gfx/menus/weapon_renders/nightvision",
  790.         "some",
  791.         "NV. Goggles",
  792.         5,
  793.         IT_PASSIVE,
  794.         0,
  795.         "",
  796.         "",
  797.  
  798.         OUTFITTING_GROUP_ACCESSORY
  799.     },
  800.  
  801.     {
  802.         "venhance_thermal",
  803.         "sound/player/pickup/ammo.wav",
  804.         { 0 },
  805.         "gfx/menus/hud/weapon_icons/thermal_icon",
  806.         "*gfx/menus/weapon_renders/thermal",
  807.         "some",
  808.         "Thermal Goggles",
  809.         5,
  810.         IT_PASSIVE,
  811.         0,
  812.         "",
  813.         "",
  814.  
  815.         OUTFITTING_GROUP_ACCESSORY
  816.     },
  817.  
  818.     // end of list marker
  819.     {NULL}
  820. };
  821.  
  822. int        bg_numItems = sizeof(bg_itemlist) / sizeof(bg_itemlist[0]) - 1;
  823.  
  824.  
  825. /*
  826. ===============
  827. BG_FindWeaponItem
  828. ===============
  829. */
  830. gitem_t    *BG_FindWeaponItem ( weapon_t weapon ) 
  831. {
  832.     gitem_t    *it;
  833.     
  834.     for ( it = bg_itemlist + 1 ; it->classname ; it++) 
  835.     {
  836.         if ( it->giType == IT_WEAPON && it->giTag == weapon ) 
  837.         {
  838.             return it;
  839.         }
  840.     }
  841.  
  842.     Com_Error( ERR_DROP, "Couldn't find item for weapon %i", weapon);
  843.     return NULL;
  844. }
  845.  
  846. /*
  847. ===============
  848. BG_FindItem
  849. ===============
  850. */
  851. gitem_t    *BG_FindItem( const char *pickupName ) 
  852. {
  853.     gitem_t    *it;
  854.     
  855.     for ( it = bg_itemlist + 1 ; it->classname ; it++ ) 
  856.     {
  857.         if ( !Q_stricmp( it->pickup_name, pickupName ) )
  858.         {
  859.             return it;
  860.         }
  861.     }
  862.  
  863.     return NULL;
  864. }
  865. /*
  866. ===============
  867. BG_FindClassnameItem
  868. ===============
  869. */
  870. gitem_t    *BG_FindClassnameItem ( const char *classname ) 
  871. {
  872.     gitem_t    *it;
  873.     
  874.     for ( it = bg_itemlist + 1 ; it->classname ; it++ ) 
  875.     {
  876.         if ( !Q_stricmp( it->classname, classname ) )
  877.         {
  878.             return it;
  879.         }
  880.     }
  881.  
  882.     return NULL;
  883. }
  884.  
  885. /*
  886. ============
  887. BG_PlayerTouchesItem
  888.  
  889. Items can be picked up without actually touching their physical bounds to make
  890. grabbing them easier
  891. ============
  892. */
  893. qboolean BG_PlayerTouchesItem( playerState_t *ps, entityState_t *item, int atTime ) 
  894. {
  895.     vec3_t    origin;
  896.  
  897.     BG_EvaluateTrajectory( &item->pos, atTime, origin );
  898.  
  899.     // we are ignoring ducked differences here
  900.     if ( ps->origin[0] - origin[0] > 36   || 
  901.          ps->origin[0] - origin[0] < -36  ||
  902.          ps->origin[1] - origin[1] > 36   ||
  903.          ps->origin[1] - origin[1] < -36  ||
  904.          ps->origin[2] - origin[2] > 55   ||
  905.          ps->origin[2] - origin[2] < -50     ) 
  906.     {
  907.         return qfalse;
  908.     }
  909.  
  910.     return qtrue;
  911. }
  912.  
  913. /*
  914. ================
  915. BG_CanItemBeGrabbed
  916.  
  917. Returns false if the item should not be picked up.
  918. This needs to be the same for client side prediction and server use.
  919. ================
  920. */
  921. qboolean BG_CanItemBeGrabbed( int gametype, const entityState_t *ent, const playerState_t *ps ) 
  922. {
  923.     gitem_t    *item;
  924.  
  925.     if ( ent->modelindex < 1 || ent->modelindex >= bg_numItems ) 
  926.     {
  927.         Com_Error( ERR_DROP, "BG_CanItemBeGrabbed: index out of range" );
  928.     }
  929.  
  930.     item = &bg_itemlist[ent->modelindex];
  931.  
  932.     // Can the item be picked up yet?
  933.     if ( ent->eFlags & EF_NOPICKUP )
  934.     {
  935.         return qfalse;
  936.     }
  937.  
  938.     switch( item->giType ) 
  939.     {
  940.         case IT_WEAPON:
  941.  
  942.             // See if this player is under limited inventory restrictions.  The truth is that
  943.             // all players on the server will be under the same restrictions, but by doing it this
  944.             // way its easy to get info to the bg-code.
  945.             if ( ps->pm_flags & PMF_LIMITED_INVENTORY )
  946.             {
  947.                 int            primary   = 0;
  948.                 int            secondary = 0;
  949.                 weapon_t    weapon;
  950.  
  951.                 switch ( item->outfittingGroup )
  952.                 {
  953.                     case OUTFITTING_GROUP_PRIMARY:
  954.                         primary++;
  955.                         break;
  956.  
  957.                     case OUTFITTING_GROUP_SECONDARY:
  958.                         secondary++;
  959.                         break;
  960.  
  961.                     // We only have restrictions on primary and secondary items
  962.                     default:
  963.                         return qtrue;
  964.                 }
  965.  
  966.                 for ( weapon = WP_KNIFE + 1; weapon < WP_NUM_WEAPONS; weapon ++ )
  967.                 {
  968.                     gitem_t* witem;
  969.  
  970.                     if ( !( ps->stats[STAT_WEAPONS] & (1<<weapon) ) )
  971.                     {
  972.                         continue;
  973.                     }
  974.  
  975.                     witem = BG_FindWeaponItem ( weapon );
  976.                     if ( !witem )
  977.                     {
  978.                         continue;
  979.                     }
  980.                     
  981.                     switch ( witem->outfittingGroup )
  982.                     {
  983.                         case OUTFITTING_GROUP_PRIMARY:
  984.                             primary++;
  985.                             break;
  986.  
  987.                         case OUTFITTING_GROUP_SECONDARY:
  988.                             secondary++;
  989.                             break;
  990.                     }
  991.                 }
  992.  
  993.                 // Cant hold 2 of either primary or secondary
  994.                 if ( primary > 1 || secondary > 1 )
  995.                 {
  996.                     return qfalse;
  997.                 }
  998.  
  999.                 return qtrue;
  1000.             }
  1001.  
  1002.             // If you dont have it then pick it up
  1003.             if ( !(ps->stats[STAT_WEAPONS] & (1<<item->giTag) ) )
  1004.             {
  1005.                 return qtrue;            
  1006.             }
  1007.  
  1008.             // If you already have the weapon and have full ammo, then dont pick it up
  1009.             if ( ps->ammo[weaponData[item->giTag].attack[ATTACK_NORMAL].ammoIndex] >= ammoData[weaponData[item->giTag].attack[ATTACK_NORMAL].ammoIndex].max) 
  1010.             {
  1011.                 if ( BG_WeaponHasAlternateAmmo ( item->giTag ) )
  1012.                 {
  1013.                     if ( ps->ammo[weaponData[item->giTag].attack[ATTACK_ALTERNATE].ammoIndex] >= ammoData[weaponData[item->giTag].attack[ATTACK_ALTERNATE].ammoIndex].max )
  1014.                     {
  1015.                         return qfalse;
  1016.                     }
  1017.                 }
  1018.                 else
  1019.                 {
  1020.                     return qfalse;        
  1021.                 }
  1022.             }
  1023.  
  1024.             return qtrue;
  1025.  
  1026.         case IT_AMMO:
  1027.  
  1028.             if ( ps->ammo[item->giTag] >= ammoData[item->giTag].max) 
  1029.             {
  1030.                 return qfalse;        // can't hold any more
  1031.             }
  1032.             return qtrue;
  1033.  
  1034.         case IT_ARMOR:
  1035.  
  1036.             if ( ps->stats[STAT_ARMOR] >= MAX_ARMOR ) 
  1037.             {
  1038.                 return qfalse;
  1039.             }
  1040.  
  1041.             return qtrue;
  1042.  
  1043.         case IT_HEALTH:
  1044.  
  1045.             if ( item->quantity == 5 || item->quantity == 100 ) 
  1046.             {
  1047.                 if ( ps->stats[STAT_HEALTH] >= MAX_HEALTH ) 
  1048.                 {
  1049.                     return qfalse;
  1050.                 }
  1051.  
  1052.                 return qtrue;
  1053.             }
  1054.  
  1055.             if ( ps->stats[STAT_HEALTH] >= MAX_HEALTH ) 
  1056.             {
  1057.                 return qfalse;
  1058.             }
  1059.  
  1060.             return qtrue;
  1061.         
  1062.         case IT_GAMETYPE:
  1063.             
  1064.             // Can only have one of a given item.  This is for when there are 
  1065.             // multiple items floating around with the same name
  1066.             if ( ps->stats[STAT_GAMETYPE_ITEMS] & (1<<item->giTag) )
  1067.             {
  1068.                 return qfalse;
  1069.             }
  1070.  
  1071.             // If both teams are checked then its ok to pick it up
  1072.             if ( (ent->eFlags & EF_BLUETEAM) && (ent->eFlags & EF_REDTEAM) )
  1073.             {
  1074.                 return qtrue;
  1075.             }
  1076.  
  1077.             if ( (ent->eFlags & EF_BLUETEAM) && !(ps->persistant[PERS_TEAM]==TEAM_BLUE) )
  1078.             {
  1079.                 return qfalse;
  1080.             }
  1081.  
  1082.             if ( (ent->eFlags & EF_REDTEAM) && !(ps->persistant[PERS_TEAM]==TEAM_RED) )
  1083.             {
  1084.                 return qfalse;
  1085.             }
  1086.  
  1087.             return qtrue;
  1088.  
  1089.         case IT_BAD:
  1090.             Com_Error( ERR_DROP, "BG_CanItemBeGrabbed: IT_BAD" );
  1091.             break;
  1092.  
  1093.         case IT_BACKPACK:
  1094.         {
  1095.             int i;
  1096.  
  1097.             // Not full health then pick it up
  1098.             if ( ps->stats[STAT_HEALTH] != MAX_HEALTH )
  1099.             {
  1100.                 return qtrue;
  1101.             }
  1102.  
  1103.             // Not full armor and dont have goggles then pick it up
  1104.             if ( !ps->stats[STAT_GOGGLES] && ps->stats[STAT_ARMOR] != MAX_HEALTH )
  1105.             {
  1106.                 return qtrue;
  1107.             }
  1108.  
  1109.             for ( i = 0; i < MAX_AMMO; i ++ )
  1110.             {
  1111.                 int maxammo;
  1112.  
  1113.                 maxammo = BG_GetMaxAmmo ( ps, i );
  1114.  
  1115.                 if ( !maxammo || ps->ammo[i] >= maxammo )
  1116.                 {
  1117.                     continue;
  1118.                 }
  1119.  
  1120.                 return qtrue;
  1121.             }
  1122.  
  1123.             // Grenades are a special case because they can be depleted by just throwing them.  
  1124.             // Therefore we need to check to see if they have any of the grenades indicated in 
  1125.             // their outfitting
  1126.             if ( ps->pm_flags & PMF_LIMITED_INVENTORY )
  1127.             {
  1128.                 // No grenades, then let the pick up the backpack
  1129.                 if ( !(ps->stats[STAT_WEAPONS] & (1<<ps->stats[STAT_OUTFIT_GRENADE])) )
  1130.                 {
  1131.                     return qtrue;
  1132.                 }
  1133.             }
  1134.  
  1135.             return qfalse;
  1136.         }
  1137.  
  1138.         default:
  1139. #ifndef Q3_VM
  1140. #ifndef NDEBUG 
  1141.               Com_Printf("BG_CanItemBeGrabbed: unknown enum %d\n", item->giType );
  1142. #endif
  1143. #endif
  1144.              break;
  1145.     }
  1146.  
  1147.     return qfalse;
  1148. }
  1149.  
  1150. //======================================================================
  1151.  
  1152. /*
  1153. ================
  1154. BG_EvaluateTrajectory
  1155.  
  1156. ================
  1157. */
  1158. void BG_EvaluateTrajectory( const trajectory_t *tr, int atTime, vec3_t result ) {
  1159.     float        deltaTime;
  1160.     float        phase;
  1161.  
  1162.     switch( tr->trType ) {
  1163.     case TR_STATIONARY:
  1164.     case TR_INTERPOLATE:
  1165.         VectorCopy( tr->trBase, result );
  1166.         break;
  1167.     case TR_LINEAR:
  1168.         deltaTime = ( atTime - tr->trTime ) * 0.001;    // milliseconds to seconds
  1169.         VectorMA( tr->trBase, deltaTime, tr->trDelta, result );
  1170.         break;
  1171.     case TR_SINE:
  1172.         deltaTime = ( atTime - tr->trTime ) / (float) tr->trDuration;
  1173.         phase = sin( deltaTime * M_PI * 2 );
  1174.         VectorMA( tr->trBase, phase, tr->trDelta, result );
  1175.         break;
  1176.     case TR_LINEAR_STOP:
  1177.         if ( atTime > tr->trTime + tr->trDuration ) {
  1178.             atTime = tr->trTime + tr->trDuration;
  1179.         }
  1180.         deltaTime = ( atTime - tr->trTime ) * 0.001;    // milliseconds to seconds
  1181.         if ( deltaTime < 0 ) {
  1182.             deltaTime = 0;
  1183.         }
  1184.         VectorMA( tr->trBase, deltaTime, tr->trDelta, result );
  1185.         break;
  1186.     case TR_LIGHTGRAVITY:
  1187.         deltaTime = ( atTime - tr->trTime ) * 0.001;    // milliseconds to seconds
  1188.         VectorMA( tr->trBase, deltaTime, tr->trDelta, result );
  1189.         result[2] -= 0.3f * DEFAULT_GRAVITY * deltaTime * deltaTime;        // FIXME: local gravity...
  1190.         break;
  1191.     case TR_GRAVITY:
  1192.         deltaTime = ( atTime - tr->trTime ) * 0.001;    // milliseconds to seconds
  1193.         VectorMA( tr->trBase, deltaTime, tr->trDelta, result );
  1194.         result[2] -= 0.5 * DEFAULT_GRAVITY * deltaTime * deltaTime;        // FIXME: local gravity...
  1195.         break;
  1196.     case TR_HEAVYGRAVITY:
  1197.         deltaTime = ( atTime - tr->trTime ) * 0.001;    // milliseconds to seconds
  1198.         VectorMA( tr->trBase, deltaTime, tr->trDelta, result );
  1199.         result[2] -= 1.0 * DEFAULT_GRAVITY * deltaTime * deltaTime;        // FIXME: local gravity...
  1200.         break;
  1201.     default:
  1202.         Com_Error( ERR_DROP, "BG_EvaluateTrajectory: unknown trType: %i", tr->trTime );
  1203.         break;
  1204.     }
  1205. }
  1206.  
  1207. /*
  1208. ================
  1209. BG_EvaluateTrajectoryDelta
  1210.  
  1211. For determining velocity at a given time
  1212. ================
  1213. */
  1214. void BG_EvaluateTrajectoryDelta( const trajectory_t *tr, int atTime, vec3_t result ) {
  1215.     float    deltaTime;
  1216.     float    phase;
  1217.  
  1218.     switch( tr->trType ) {
  1219.     case TR_STATIONARY:
  1220.     case TR_INTERPOLATE:
  1221.         VectorClear( result );
  1222.         break;
  1223.     case TR_LINEAR:
  1224.         VectorCopy( tr->trDelta, result );
  1225.         break;
  1226.     case TR_SINE:
  1227.         deltaTime = ( atTime - tr->trTime ) / (float) tr->trDuration;
  1228.         phase = cos( deltaTime * M_PI * 2 );    // derivative of sin = cos
  1229.         phase *= 0.5;
  1230.         VectorScale( tr->trDelta, phase, result );
  1231.         break;
  1232.     case TR_LINEAR_STOP:
  1233.         if ( atTime > tr->trTime + tr->trDuration ) {
  1234.             VectorClear( result );
  1235.             return;
  1236.         }
  1237.         VectorCopy( tr->trDelta, result );
  1238.         break;
  1239.     case TR_LIGHTGRAVITY:
  1240.         deltaTime = ( atTime - tr->trTime ) * 0.001;    // milliseconds to seconds
  1241.         VectorCopy( tr->trDelta, result );
  1242.         result[2] -= 0.6f * DEFAULT_GRAVITY * deltaTime;        // FIXME: local gravity...
  1243.         break;
  1244.     case TR_GRAVITY:
  1245.         deltaTime = ( atTime - tr->trTime ) * 0.001;    // milliseconds to seconds
  1246.         VectorCopy( tr->trDelta, result );
  1247.         result[2] -= DEFAULT_GRAVITY * deltaTime;        // FIXME: local gravity...
  1248.         break;
  1249.     case TR_HEAVYGRAVITY:
  1250.         deltaTime = ( atTime - tr->trTime ) * 0.001;    // milliseconds to seconds
  1251.         VectorCopy( tr->trDelta, result );
  1252.         result[2] -= 2.0f * DEFAULT_GRAVITY * deltaTime;        // FIXME: local gravity...
  1253.         break;
  1254.     default:
  1255.         Com_Error( ERR_DROP, "BG_EvaluateTrajectoryDelta: unknown trType: %i", tr->trTime );
  1256.         break;
  1257.     }
  1258. }
  1259.  
  1260. char *eventnames[] = {
  1261.     "EV_NONE",
  1262.  
  1263.     "EV_FOOTSTEP",
  1264.     "EV_FOOTWADE",
  1265.     "EV_SWIM",
  1266.  
  1267.     "EV_STEP_4",
  1268.     "EV_STEP_8",
  1269.     "EV_STEP_12",
  1270.     "EV_STEP_16",
  1271.  
  1272.     "EV_FALL_SHORT",
  1273.     "EV_FALL_MEDIUM",
  1274.     "EV_FALL_FAR",
  1275.  
  1276.     "EV_JUMP",
  1277.     "EV_WATER_FOOTSTEP",
  1278.     "EV_WATER_TOUCH",    // foot touches
  1279.  
  1280.     "EV_ITEM_PICKUP",            // normal item pickups are predictable
  1281.  
  1282.     "EV_NOAMMO",
  1283.     "EV_CHANGE_WEAPON",
  1284.     "EV_FIRE_WEAPON",
  1285.     "EV_ALT_FIRE",
  1286.  
  1287.     "EV_USE",            // +Use key
  1288.  
  1289.     "EV_ITEM_RESPAWN",
  1290.     "EV_ITEM_POP",
  1291.     "EV_PLAYER_TELEPORT_IN",
  1292.     "EV_PLAYER_TELEPORT_OUT",
  1293.  
  1294.     "EV_GRENADE_BOUNCE",        // eventParm will be the soundindex
  1295.  
  1296.     "EV_PLAY_EFFECT",
  1297.  
  1298.     "EV_GENERAL_SOUND",
  1299.     "EV_GLOBAL_SOUND",        // no attenuation
  1300.     "EV_ENTITY_SOUND",
  1301.  
  1302.     "EV_GLASS_SHATTER",
  1303.  
  1304.     "EV_MISSILE_HIT",
  1305.     "EV_MISSILE_MISS",
  1306.     "EV_BULLET",                // otherEntity is the shooter
  1307.  
  1308.     "EV_PAIN",
  1309.     "EV_OBITUARY",
  1310.  
  1311.     "EV_DESTROY_GHOUL2_INSTANCE",
  1312.  
  1313.     "EV_WEAPON_CHARGE",
  1314.     "EV_WEAPON_CHARGE_ALT",
  1315.  
  1316.     "EV_DEBUG_LINE",
  1317.     "EV_TESTLINE",
  1318.     "EV_STOPLOOPINGSOUND",
  1319. };
  1320.  
  1321. /*
  1322. ===============
  1323. BG_AddPredictableEventToPlayerstate
  1324.  
  1325. Handles the sequence numbers
  1326. ===============
  1327. */
  1328.  
  1329. void    trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize );
  1330.  
  1331. void BG_AddPredictableEventToPlayerstate( int newEvent, int eventParm, playerState_t *ps ) {
  1332.  
  1333. #ifdef _DEBUG
  1334.     {
  1335.         char buf[256];
  1336.         trap_Cvar_VariableStringBuffer("showevents", buf, sizeof(buf));
  1337.         if ( atof(buf) != 0 ) {
  1338. #ifdef QAGAME
  1339.             Com_Printf(" game event svt %5d -> %5d: num = %20s parm %d\n", ps->pmove_framecount/*ps->commandTime*/, ps->eventSequence, eventnames[newEvent], eventParm);
  1340. #else
  1341.             Com_Printf("Cgame event svt %5d -> %5d: num = %20s parm %d\n", ps->pmove_framecount/*ps->commandTime*/, ps->eventSequence, eventnames[newEvent], eventParm);
  1342. #endif
  1343.         }
  1344.     }
  1345. #endif
  1346.     ps->events[ps->eventSequence & (MAX_PS_EVENTS-1)] = newEvent;
  1347.     ps->eventParms[ps->eventSequence & (MAX_PS_EVENTS-1)] = eventParm;
  1348.     ps->eventSequence++;
  1349. }
  1350.  
  1351. /*
  1352. ========================
  1353. BG_PlayerStateToEntityState
  1354.  
  1355. This is done after each set of usercmd_t on the server,
  1356. and after local prediction on the client
  1357. ========================
  1358. */
  1359. void BG_PlayerStateToEntityState( playerState_t *ps, entityState_t *s, qboolean snap ) 
  1360. {
  1361.     if ( ps->pm_type == PM_INTERMISSION || ps->pm_type == PM_SPECTATOR ) 
  1362.     {
  1363.         s->eType = ET_INVISIBLE;
  1364.     } 
  1365.     else 
  1366.     {
  1367.         s->eType = ET_PLAYER;
  1368.     }
  1369.  
  1370.     s->number = ps->clientNum;
  1371.  
  1372.     s->pos.trType = TR_INTERPOLATE;
  1373.  
  1374.     VectorCopy( ps->origin, s->pos.trBase );
  1375.     if ( snap ) 
  1376.     {
  1377.         SnapVector( s->pos.trBase );
  1378.     }
  1379.     // set the trDelta for flag direction
  1380.     VectorCopy( ps->velocity, s->pos.trDelta );
  1381.  
  1382.     s->apos.trType = TR_INTERPOLATE;
  1383.     VectorCopy( ps->viewangles, s->apos.trBase );
  1384.     if ( snap ) 
  1385.     {
  1386.         SnapVector( s->apos.trBase );
  1387.     }
  1388.  
  1389.     s->angles2[YAW] = ps->movementDir;
  1390.     s->legsAnim = ps->legsAnim;
  1391.     s->torsoAnim = ps->torsoAnim;
  1392.     s->torsoTimer = ps->torsoTimer;
  1393.     s->clientNum = ps->clientNum;        // ET_PLAYER looks here instead of at number
  1394.                                         // so corpses can also reference the proper config
  1395.     s->eFlags = ps->eFlags;
  1396.  
  1397.     if ( ps->stats[STAT_HEALTH] <= 0 || ps->pm_type == PM_DEAD ) 
  1398.     {
  1399.         s->eFlags |= EF_DEAD;
  1400.     } 
  1401.     else 
  1402.     {
  1403.         s->eFlags &= ~EF_DEAD;
  1404.     }
  1405.  
  1406.     if ( ps->pm_flags & PMF_GOGGLES_ON )
  1407.     {
  1408.         s->eFlags |= EF_GOGGLES;
  1409.     }
  1410.     else
  1411.     {
  1412.         s->eFlags &= (~EF_GOGGLES);
  1413.     }
  1414.  
  1415.     if ( ps->pm_flags & PMF_DUCKED)
  1416.     {
  1417.         s->eFlags |= EF_DUCKED;
  1418.     }
  1419.     else
  1420.     {
  1421.         s->eFlags &= (~EF_DUCKED);
  1422.     }
  1423.  
  1424.     if ( ps->externalEvent ) 
  1425.     {
  1426.         s->event = ps->externalEvent;
  1427.         s->eventParm = ps->externalEventParm;
  1428.     } 
  1429.     else if ( ps->entityEventSequence < ps->eventSequence ) 
  1430.     {
  1431.         int        seq;
  1432.  
  1433.         if ( ps->entityEventSequence < ps->eventSequence - MAX_PS_EVENTS) 
  1434.         {
  1435.             ps->entityEventSequence = ps->eventSequence - MAX_PS_EVENTS;
  1436.         }
  1437.         
  1438.         seq = ps->entityEventSequence & (MAX_PS_EVENTS-1);
  1439.         s->event = ps->events[ seq ] | ( ( ps->entityEventSequence & 3 ) << 8 );
  1440.         s->eventParm = ps->eventParms[ seq ];
  1441.         ps->entityEventSequence++;
  1442.     }
  1443.  
  1444.     s->weapon           = ps->weapon;
  1445.     s->groundEntityNum = ps->groundEntityNum;
  1446.     s->gametypeitems   = ps->stats[STAT_GAMETYPE_ITEMS];
  1447.     s->loopSound       = ps->loopSound;
  1448.     s->generic1           = ps->generic1;
  1449.     s->leanOffset       = (int) BG_CalculateLeanOffset ( ps->leanTime ) + LEAN_OFFSET;
  1450.     s->time               = ps->persistant[PERS_SPAWN_COUNT];
  1451. }
  1452.  
  1453. /*
  1454. ========================
  1455. BG_PlayerStateToEntityStateExtraPolate
  1456.  
  1457. This is done after each set of usercmd_t on the server,
  1458. and after local prediction on the client
  1459. ========================
  1460. */
  1461. void BG_PlayerStateToEntityStateExtraPolate( playerState_t *ps, entityState_t *s, int time, qboolean snap ) 
  1462. {
  1463.     if ( ps->pm_type == PM_INTERMISSION || ps->pm_type == PM_SPECTATOR ) 
  1464.     {
  1465.         s->eType = ET_INVISIBLE;
  1466.     } 
  1467.     else 
  1468.     {
  1469.         s->eType = ET_PLAYER;
  1470.     }
  1471.  
  1472.     s->number = ps->clientNum;
  1473.  
  1474.     s->pos.trType = TR_LINEAR_STOP;
  1475.  
  1476.     VectorCopy( ps->origin, s->pos.trBase );
  1477.     if ( snap ) 
  1478.     {
  1479.         SnapVector( s->pos.trBase );
  1480.     }
  1481.     
  1482.     // set the trDelta for flag direction and linear prediction
  1483.     VectorCopy( ps->velocity, s->pos.trDelta );
  1484.     // set the time for linear prediction
  1485.     s->pos.trTime = time;
  1486.     // set maximum extra polation time
  1487.     s->pos.trDuration = 50; // 1000 / sv_fps (default = 20)
  1488.  
  1489.     s->apos.trType = TR_INTERPOLATE;
  1490.     VectorCopy( ps->viewangles, s->apos.trBase );
  1491.     if ( snap ) 
  1492.     {
  1493.         SnapVector( s->apos.trBase );
  1494.     }
  1495.  
  1496.     s->angles2[YAW] = ps->movementDir;
  1497.     s->legsAnim = ps->legsAnim;
  1498.     s->torsoAnim = ps->torsoAnim;
  1499.     s->torsoTimer = ps->torsoTimer;
  1500.     s->clientNum = ps->clientNum;        // ET_PLAYER looks here instead of at number
  1501.                                         // so corpses can also reference the proper config
  1502.     s->eFlags = ps->eFlags;
  1503.  
  1504.     if ( ps->stats[STAT_HEALTH] <= 0 || ps->pm_type == PM_DEAD ) 
  1505.     {
  1506.         s->eFlags |= EF_DEAD;
  1507.     } 
  1508.     else 
  1509.     {
  1510.         s->eFlags &= ~EF_DEAD;
  1511.     }
  1512.  
  1513.     if ( ps->pm_flags & PMF_GOGGLES_ON )
  1514.     {
  1515.         s->eFlags |= EF_GOGGLES;
  1516.     }
  1517.     else
  1518.     {
  1519.         s->eFlags &= (~EF_GOGGLES);
  1520.     }
  1521.  
  1522.     if ( ps->pm_flags & PMF_DUCKED)
  1523.     {
  1524.         s->eFlags |= EF_DUCKED;
  1525.     }
  1526.     else
  1527.     {
  1528.         s->eFlags &= (~EF_DUCKED);
  1529.     }
  1530.  
  1531.     if ( ps->externalEvent ) 
  1532.     {
  1533.         s->event = ps->externalEvent;
  1534.         s->eventParm = ps->externalEventParm;
  1535.     } 
  1536.     else if ( ps->entityEventSequence < ps->eventSequence ) 
  1537.     {
  1538.         int    seq;
  1539.  
  1540.         if ( ps->entityEventSequence < ps->eventSequence - MAX_PS_EVENTS) 
  1541.         {
  1542.             ps->entityEventSequence = ps->eventSequence - MAX_PS_EVENTS;
  1543.         }
  1544.         seq = ps->entityEventSequence & (MAX_PS_EVENTS-1);
  1545.         s->event = ps->events[ seq ] | ( ( ps->entityEventSequence & 3 ) << 8 );
  1546.         s->eventParm = ps->eventParms[ seq ];
  1547.         ps->entityEventSequence++;
  1548.     }
  1549.  
  1550.     // Direct copies
  1551.     s->weapon           = ps->weapon;
  1552.     s->groundEntityNum = ps->groundEntityNum;
  1553.     s->gametypeitems   = ps->stats[STAT_GAMETYPE_ITEMS];
  1554.     s->loopSound       = ps->loopSound;
  1555.     s->generic1           = ps->generic1;
  1556.     s->leanOffset       = (int) BG_CalculateLeanOffset ( ps->leanTime ) + LEAN_OFFSET;
  1557.     s->time               = ps->persistant[PERS_SPAWN_COUNT];
  1558. }
  1559.  
  1560.